<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新增游戏标签')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-tag-add">
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">标签名称：</label>
                    <div class="col-sm-8">
                        <input name="name" class="form-control" type="text" required>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label is-required">父级标签id(不选默认创建根标签)：</label>
                    <div class="col-sm-8">
                        <div class="input-group">
                            <input id="treeId" name="pid" type="hidden" th:value="${bizTag?.id}"/>
                            <input class="form-control" type="text" onclick="selectTagTree()" id="treeName" readonly="true" th:value="${bizTag?.name}" placeholder="不选默认创建为根标签" required>
                            <span class="input-group-addon"><i class="fa fa-search"></i></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-xs-12">
                <div class="form-group">
                    <label class="col-sm-3 control-label">备注：</label>
                    <div class="col-sm-8">
                        <textarea name="remark" class="form-control"></textarea>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "biz/tag"
        $("#form-tag-add").validate({
            focusCleanup: true
        });

        function submitHandler() {
            $.operate.save(prefix + "/add", $('#form-tag-add').serialize());
        }

        /*游戏标签-新增-选择父游戏标签树*/
        function selectTagTree() {
            var options = {
                title: '游戏标签选择',
                width: "380",
                url: prefix + "/selectTagTree/" + $("#treeId").val(),
                callBack: doSubmit
            };
            $.modal.openOptions(options);
        }

        function doSubmit(index, layero){
            var body = $.modal.getChildFrame(index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            $.modal.close(index);
        }
    </script>
</body>
</html>